#include <stdio.h>
#include <stdlib.h>
#include "BST.h"

int main(void)
{
        BST bst;
        datatype ar[] = {45, 12, 53, 3, 37, 100, 24, 61, 90, 78};
        int n = sizeof(ar) / sizeof(datatype);

        InitBSTree(&bst);

        for (int i = 0; i < n; i++)
                InsertBSTree(&bst.root, &ar[i]);

        printf("min value = %d\n", Min(bst.root)->data);
        printf("max value = %d\n", Max(bst.root)->data);
        printf("二叉排序的结果为：\n");
        Sort(bst.root);
        printf("\n");

        datatype value = 3;
        printf("查找数据 %d ", value);
        BSTNode *p = SearchBSTree(bst.root, &value);
        if (p == NULL)
                printf("未找到数据：%d\n", value);
        else
                printf("找到数据：%d\n", value);

        printf("删除数据 %d 后的顺序为：\n", value);
        RemoveBSTree(&bst.root, &value);
        Sort(bst.root);
        printf("\n");

        exit(EXIT_SUCCESS);
}
